//
//  ImageModelCell.m
//  Otaku
//
//  Created by lanou3g on 16/5/16.
//  Copyright © 2016年 Liuwx. All rights reserved.
//

#import "ImageModelCell.h"
@interface ImageModelCell()
@property (weak, nonatomic) IBOutlet UIImageView *userImageView;

@property (weak, nonatomic) IBOutlet UIImageView *bigImageView;
@property (weak, nonatomic) IBOutlet UILabel *userNameLabel;


@end

static CGFloat height = 0;

@implementation ImageModelCell

- (void)setModel:(ImageModel *)model {
    _model = model;
    self.userImageView.layer.cornerRadius = 15;
    self.userImageView.layer.masksToBounds = YES;
    [self.userImageView sd_setImageWithURL:[NSURL URLWithString:self.model.user[@"avatar_url"]]];
    self.userNameLabel.text = self.model.user[@"name"];
    [self.bigImageView sd_setImageWithURL:[NSURL URLWithString:self.model.large_image[@"url_list"][0][@"url"]]];
    
    
    CGFloat Width = [UIScreen mainScreen].bounds.size.width;
    CGFloat h = [self.model.large_image[@"r_height"] floatValue];
    CGFloat w = [self.model.large_image[@"width"] floatValue];
    
    CGFloat ImageHeight = h * Width / w;
    if (h == 0 || w == 0) {
        ImageHeight = 0;
    }
    height = ImageHeight + 60;
    
}

+ (CGFloat)cellHeight {
    return height;
}
@end
